package com.shi.controller;

import com.shi.common.Result;
import com.shi.entity.dto.SysLogPageDto;
import com.shi.entity.vo.PageVO;
import com.shi.service.SysLogService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;

@Api(tags = "系统日志")
@RestController
@RequestMapping("/sysLog")
public class SysLogController {

    @Resource
    private SysLogService sysLogService;

    @ApiOperation("分页查询")
    @GetMapping("/page")
    public Result page(SysLogPageDto sysLogPageDto){
        PageVO page = sysLogService.page(sysLogPageDto);
        return Result.ok(page);
    }

    @ApiOperation("通过ids批量删除日志")
    @PostMapping("/remove/batch")
    public Result removeBatch(@RequestBody List<Long> ids){
        sysLogService.removeBatchByIds(ids);
        return Result.ok();
    }

    @ApiOperation("清空日志")
    @PostMapping("/clearAll")
    public Result clearAll(){
        sysLogService.remove(null);
        return Result.ok();
    }
}
